// 选择售后类型
import { PACKAGE_ORDER_PAGE } from '../../../constants/route';
import { AFTER_SALE_TYPE_LIST } from '../../../constants/order';
import { redirectTo } from '../../../common/env';
import { getAfterSaleOrderInfo } from '../../../biztools/wex';

Page({
    data: {
        orderInfo: {},
        goodsId: '',
        goodsList: [],
        typeList: AFTER_SALE_TYPE_LIST,
    },
    onLoad: function (options) {
        const { goodsId } = options;
        console.log('AfterSaleType => 商品id为：', goodsId)
        const orderInfo = getAfterSaleOrderInfo();
        this.setData({
            goodsList: (orderInfo.details || []).filter(item => `${item.orderDetailId}` === `${goodsId}`),
            orderInfo,
            goodsId,
        });
    },

    // 选择售后类型
    selectAfterSaleType: function (event) {
        const { type } = event.currentTarget.dataset;
        redirectTo(PACKAGE_ORDER_PAGE.orderAfterSaleApply, {
            type,
            goodsId: this.data.goodsId,
        });
    },
})